From 8677ed959d6c91f278151133106dc192a0662d54 Mon Sep 17 00:00:00 2001 From: Hans Breuer Date: Fri, 13 Jun 2008 08:36:26 +0000 Subject: [PATCH] check surface status after ceating a pdf. Avoids crashing when the target 2008-05-23 Hans Breuer * gtk/gtkprintoperation.c : check surface status after ceating a pdf. Avoids crashing when the target can not be written, bug #537685 * gdk/win32/gdkdisplay-win32.c : runtime linking of ProcessIdToSessionId * gtk/gtkfilesystem.c : variadic macros are not supported with c89 and it was not needed here anyway. svn path=/trunk/; revision=20370 --- ChangeLog | 10 ++++++++++ gdk/win32/gdkdisplay-win32.c | 5 ++++- gtk/gtkfilesystem.c | 4 ++-- gtk/gtkprintoperation.c | 11 +++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a50541dce..c35c546c70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-05-23 Hans Breuer + + * gtk/gtkprintoperation.c : check surface status after ceating a pdf. + Avoids crashing when the target can not be written, bug #537685 + + * gdk/win32/gdkdisplay-win32.c : runtime linking of ProcessIdToSessionId + + * gtk/gtkfilesystem.c : variadic macros are not supported with c89 and + it was not needed here anyway. + 2008-06-13 Matthias Clasen * gtk/gtkentry.c (gtk_entry_draw_frame): Fix frame size allocation. diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index 43dcb74575..1874c608e9 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -241,6 +241,8 @@ gdk_display_get_name (GdkDisplay *display) DWORD session_id; char *display_name; static const char *display_name_cache = NULL; + typedef BOOL (* PFN_ProcessIdToSessionId) (DWORD, DWORD *); + PFN_ProcessIdToSessionId processIdToSessionId; g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); @@ -275,7 +277,8 @@ gdk_display_get_name (GdkDisplay *display) window_station_name = "WinSta0"; } - if (!ProcessIdToSessionId (GetCurrentProcessId (), &session_id)) + processIdToSessionId = (PFN_ProcessIdToSessionId) GetProcAddress (GetModuleHandle ("kernel32.dll"), "ProcessIdToSessionId"); + if (!processIdToSessionId || !processIdToSessionId (GetCurrentProcessId (), &session_id)) session_id = 0; display_name = g_strdup_printf ("%ld\\%s\\%s", diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c index 027f1bb49c..c78ae77d38 100644 --- a/gtk/gtkfilesystem.c +++ b/gtk/gtkfilesystem.c @@ -29,9 +29,9 @@ /* #define DEBUG_MODE */ #ifdef DEBUG_MODE -#define DEBUG(x...) g_debug (x); +#define DEBUG(x) g_debug (x); #else -#define DEBUG(x...) +#define DEBUG(x) #endif #define GTK_FILE_SYSTEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_FILE_SYSTEM, GtkFileSystemPrivate)) diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c index 3b7bff403d..ff0edff631 100644 --- a/gtk/gtkprintoperation.c +++ b/gtk/gtkprintoperation.c @@ -1840,6 +1840,17 @@ run_pdf (GtkPrintOperation *op, surface = cairo_pdf_surface_create (priv->export_filename, width, height); + if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) + { + g_set_error (&priv->error, + GTK_PRINT_ERROR, + GTK_PRINT_ERROR_GENERAL, + cairo_status_to_string (cairo_surface_status (surface))); + *do_print = FALSE; + return GTK_PRINT_OPERATION_RESULT_ERROR; + } + + /* this would crash on a nil surface */ cairo_surface_set_fallback_resolution (surface, 300, 300); priv->platform_data = surface; -- 2.30.2